package com.yixun.qfbao.apidto;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils;

import com.yixun.qfbao.model.Company;
import com.yixun.qfbao.model.ModelInfo;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @author zilong.liu
 * @date 2021-2-23
 *
 * desc:
 *     	获取合作机构注册列表的返回值
 */
@Data
public class AgentCompanyRegesitResDto implements Serializable {

	private static final long serialVersionUID = -2375348367543417171L;
	
	@ApiModelProperty("id")
	private Long id;
	
	@ApiModelProperty("公司名称")
	private String companyName;
	
	@ApiModelProperty("省份名称")
	private String provinceName;
	
	@ApiModelProperty("城市名称")
	private String cityName;
	
	@ApiModelProperty("地址详情")
	private String adress;
	
	@ApiModelProperty("管理员姓名")
	private String adminName;
	
	@ApiModelProperty("管理员电话")
	private String adminPhone;
	
	@ApiModelProperty("注册时间")
	private String createTime;
	
	@ApiModelProperty("审核状态 0、待审核 1、审核失败 2、审核成功")
	private String status;
	
	@ApiModelProperty("备注")
	private String remark;
	
	private List<ModelInfoResDto> modelInfoResDtoList;
	
	/**
	 * 添加modelInfoResDto 进当前集合元素中
	 */
	public void addModelInfoResDto(ModelInfo modelInfo) {
		if(CollectionUtils.isEmpty(modelInfoResDtoList)) {
			modelInfoResDtoList = new ArrayList<>();
		}
		if(this.id.longValue() == modelInfo.getRelId().longValue()) {
			ModelInfoResDto modelInfoResDto = new ModelInfoResDto();
			modelInfoResDto.setName(modelInfo.getModelName());
			modelInfoResDto.setDisplayType(modelInfo.getDisplayType());
			modelInfoResDto.setValue(modelInfo.getModelValue());
			modelInfoResDtoList.add(modelInfoResDto);
		}
	}
	
	/**
	 *  转换company 对象至当前对象
	 * @return
	 */
	public static AgentCompanyRegesitResDto converCompanyToThis(Company company) {
		AgentCompanyRegesitResDto agentCompanyRegesitResDto = new AgentCompanyRegesitResDto();
		BeanUtils.copyProperties(company, agentCompanyRegesitResDto);
		agentCompanyRegesitResDto.setAdminName(company.getChargeMan());
		agentCompanyRegesitResDto.setAdminPhone(company.getPhone());
		return agentCompanyRegesitResDto;
	}
	
}
